home *** CD-ROM | disk | FTP | other *** search
- *** /tmp/,RCSt1725321 Fri Nov 22 18:45:20 1991
- --- sunMouse.c Sun Apr 22 23:36:35 1990
- ***************
- *** 73,79 ****
-
- static void sunMouseCtrl();
- static int sunMouseGetMotionEvents();
- ! static Firm_event *sunMouseGetEvents();
- static void sunMouseProcessEvent();
- static void sunMouseDoneEvents();
-
- --- 73,79 ----
-
- static void sunMouseCtrl();
- static int sunMouseGetMotionEvents();
- ! static Mouse_Event *sunMouseGetEvents();
- static void sunMouseProcessEvent();
- static void sunMouseDoneEvents();
-
- ***************
- *** 108,113 ****
- --- 108,116 ----
- * keyboard. We have arbitrarily chosen to enable and disable windowFd
- * in the keyboard routine sunKbdProc rather than in sunMouseProc.
- *
- + * In Sprite, things work like under suntools, in that /dev/mouse
- + * handles both mouse and keyboard.
- + *
- *-----------------------------------------------------------------------
- */
- int
- ***************
- *** 127,151 ****
- return (!Success);
- }
-
- - if (! sunUseSunWindows()) {
- - if (sysMousePriv.fd >= 0) {
- - fd = sysMousePriv.fd;
- - } else {
- - fd = open ("/dev/mouse", O_RDWR, 0);
- - if (fd < 0) {
- - Error ("Opening /dev/mouse");
- - return (!Success);
- - }
- - if (fcntl (fd, F_SETFL, (FNDELAY|FASYNC)) < 0
- - || fcntl(fd, F_SETOWN, getpid()) < 0) {
- - perror("sunMouseProc");
- - ErrorF("Can't set up mouse on fd %d\n", fd);
- - }
- -
- - sysMousePriv.fd = fd;
- - }
- - }
- -
- sunMousePriv.bmask = 0;
- sunMousePriv.mouseMoved = FALSE;
- sysMousePriv.dx = 0;
- --- 130,135 ----
- ***************
- *** 161,198 ****
- break;
-
- case DEVICE_ON:
- - if (! sunUseSunWindows()) {
- - if (ioctl (((PtrPrivPtr)pMouse->devicePrivate)->fd,
- - VUIDGFORMAT, &oformat) < 0) {
- - Error ("VUIDGFORMAT");
- - return(!Success);
- - }
- - format = VUID_FIRM_EVENT;
- - if (ioctl (((PtrPrivPtr)pMouse->devicePrivate)->fd,
- - VUIDSFORMAT, &format) < 0) {
- - Error ("VUIDSFORMAT");
- - return(!Success);
- - }
- - AddEnabledDevice (((PtrPrivPtr)pMouse->devicePrivate)->fd);
- - }
- -
- pMouse->on = TRUE;
- break;
-
- case DEVICE_CLOSE:
- - if (! sunUseSunWindows()) {
- - if (ioctl (((PtrPrivPtr)pMouse->devicePrivate)->fd,
- - VUIDSFORMAT, &oformat) < 0) {
- - Error ("VUIDSFORMAT");
- - }
- - }
- break;
-
- case DEVICE_OFF:
- pMouse->on = FALSE;
- - if (! sunUseSunWindows()) {
- - RemoveEnabledDevice (((PtrPrivPtr)pMouse->devicePrivate)->fd);
- - }
- break;
- }
- return (Success);
- --- 145,158 ----
- ***************
- *** 250,256 ****
- * Return the events waiting in the wings for the given mouse.
- *
- * Results:
- ! * A pointer to an array of Firm_events or (Firm_event *)0 if no events
- * The number of events contained in the array.
- * A boolean as to whether more events might be available.
- *
- --- 210,216 ----
- * Return the events waiting in the wings for the given mouse.
- *
- * Results:
- ! * A pointer to an array of Mouse_Events or (Mouse_Event *)0 if no events
- * The number of events contained in the array.
- * A boolean as to whether more events might be available.
- *
- ***************
- *** 258,290 ****
- * None.
- *-----------------------------------------------------------------------
- */
- ! static Firm_event *
- ! sunMouseGetEvents (pMouse, pNumEvents, pAgain)
- DevicePtr pMouse; /* Mouse to read */
- int *pNumEvents; /* Place to return number of events */
- - Bool *pAgain; /* whether more might be available */
- {
- ! int nBytes; /* number of bytes of events available. */
- ! register PtrPrivPtr pPriv;
- ! static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
- !
- ! pPriv = (PtrPrivPtr) pMouse->devicePrivate;
- !
- ! nBytes = read (pPriv->fd, evBuf, sizeof(evBuf));
- !
- ! if (nBytes < 0) {
- ! if (errno == EWOULDBLOCK) {
- ! *pNumEvents = 0;
- ! *pAgain = FALSE;
- ! } else {
- ! Error ("Reading mouse");
- ! FatalError ("Could not read from mouse");
- ! }
- ! } else {
- ! *pNumEvents = nBytes / sizeof (Firm_event);
- ! *pAgain = (nBytes == sizeof (evBuf));
- ! }
- ! return (evBuf);
- }
-
-
- --- 218,229 ----
- * None.
- *-----------------------------------------------------------------------
- */
- ! static Mouse_Event *
- ! sunMouseGetEvents (pMouse, pNumEvents)
- DevicePtr pMouse; /* Mouse to read */
- int *pNumEvents; /* Place to return number of events */
- {
- ! return (Mouse_Event *)0;
- }
-
-
- ***************
- *** 336,399 ****
- *-----------------------------------------------------------------------
- */
- static void
- ! sunMouseProcessEvent (pMouse, fe)
- DevicePtr pMouse; /* Mouse from which the event came */
- ! Firm_event *fe; /* Event to process */
- {
- xEvent xE;
- register PtrPrivPtr pPriv; /* Private data for pointer */
- register SunMsPrivPtr pSunPriv; /* Private data for mouse */
- register int bmask; /* Temporary button mask */
-
- pPriv = (PtrPrivPtr)pMouse->devicePrivate;
- pSunPriv = (SunMsPrivPtr) pPriv->devPrivate;
-
- ! xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
- !
- ! switch (fe->id)
- ! {
- ! case MS_LEFT:
- ! case MS_MIDDLE:
- ! case MS_RIGHT:
- ! /*
- ! * A button changed state. Sometimes we will get two events
- ! * for a single state change. Should we get a button event which
- ! * reflects the current state of affairs, that event is discarded.
- ! *
- ! * Mouse buttons start at 1.
- ! */
- ! xE.u.u.detail = (fe->id - MS_LEFT) + 1;
- ! bmask = 1 << xE.u.u.detail;
- ! if (fe->value == VKEY_UP) {
- ! if (pSunPriv->bmask & bmask) {
- ! xE.u.u.type = ButtonRelease;
- ! pSunPriv->bmask &= ~bmask;
- ! } else {
- ! return;
- ! }
- ! } else {
- ! if ((pSunPriv->bmask & bmask) == 0) {
- ! xE.u.u.type = ButtonPress;
- ! pSunPriv->bmask |= bmask;
- ! } else {
- ! return;
- ! }
- ! }
- ! /*
- ! * If the mouse has moved, we must update any interested client
- ! * as well as DIX before sending a button event along.
- ! */
- ! if (pSunPriv->mouseMoved) {
- ! sunMouseDoneEvents (pMouse, FALSE);
- ! }
-
- - miPointerPosition (screenInfo.screens[0],
- - &xE.u.keyButtonPointer.rootX,
- - &xE.u.keyButtonPointer.rootY);
- -
- - (* pMouse->processInputProc) (&xE, pMouse, 1);
- - break;
- - case LOC_X_DELTA:
- /*
- * When we detect a change in the mouse coordinates, we call
- * the cursor module to move the cursor. It has the option of
- --- 275,296 ----
- *-----------------------------------------------------------------------
- */
- static void
- ! sunMouseProcessEvent (pMouse, ev)
- DevicePtr pMouse; /* Mouse from which the event came */
- ! Mouse_Event *ev; /* Event to process */
- {
- xEvent xE;
- register PtrPrivPtr pPriv; /* Private data for pointer */
- register SunMsPrivPtr pSunPriv; /* Private data for mouse */
- register int bmask; /* Temporary button mask */
- + register int button;
-
- pPriv = (PtrPrivPtr)pMouse->devicePrivate;
- pSunPriv = (SunMsPrivPtr) pPriv->devPrivate;
-
- ! xE.u.keyButtonPointer.time = ev->time;
- ! bmask = ev->key ^ pSunPriv->bmask;
-
- /*
- * When we detect a change in the mouse coordinates, we call
- * the cursor module to move the cursor. It has the option of
- ***************
- *** 403,438 ****
- * What should be done if it goes off the screen? Move to another
- * screen? For now, we just force the pointer to stay on the
- * screen...
- ! */
- ! pPriv->dx += MouseAccelerate (pMouse, fe->value);
- !
- ! #ifdef SUN_ALL_MOTION
- ! miPointerDeltaCursor (screenInfo.screens[0], pPriv->dx, pPriv->dy, TRUE);
- ! pPriv->dx = 0;
- ! pPriv->dy = 0;
- ! #else
- ! ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
- ! #endif
- ! break;
- ! case LOC_Y_DELTA:
- ! /*
- * For some reason, motion up generates a positive y delta
- * and motion down a negative delta, so we must subtract
- * here instead of add...
- */
- ! pPriv->dy -= MouseAccelerate (pMouse, fe->value);
- ! #ifdef SUN_ALL_MOTION
- ! miPointerDeltaCursor (screenInfo.screens[0], pPriv->dx, pPriv->dy, TRUE);
- ! pPriv->dx = 0;
- ! pPriv->dy = 0;
- ! #else
- ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
- ! #endif SUN_ALL_MOTION
- ! break;
- ! default:
- ! FatalError ("sunMouseProcessEvent: unrecognized id\n");
- ! break;
- }
- }
-
- /*ARGSUSED*/
- --- 300,339 ----
- * What should be done if it goes off the screen? Move to another
- * screen? For now, we just force the pointer to stay on the
- * screen...
- ! *
- * For some reason, motion up generates a positive y delta
- * and motion down a negative delta, so we must subtract
- * here instead of add...
- */
- ! if (ev->deltaX) {
- ! pPriv->dx += MouseAccelerate (pMouse, ev->deltaX);
- ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
- ! }
- !
- ! if (ev->deltaY) {
- ! pPriv->dy -= MouseAccelerate (pMouse, ev->deltaY);
- ! ((SunMsPrivPtr)pPriv->devPrivate)->mouseMoved = TRUE;
- ! }
- !
- ! if (ev->key ^ pSunPriv->bmask) {
- ! sunMouseDoneEvents (pMouse, FALSE);
- ! }
- !
- ! xE.u.keyButtonPointer.time = ev->time;
- ! for (bmask = 4, button = 1; bmask != 0; bmask >>= 1, button++) {
- ! if ((ev->key & bmask) != (pSunPriv->bmask & bmask)) {
- ! xE.u.u.type = (ev->key & bmask) ? ButtonRelease : ButtonPress;
- ! xE.u.u.detail = button;
- !
- ! miPointerPosition (screenInfo.screens[0],
- ! &xE.u.keyButtonPointer.rootX,
- ! &xE.u.keyButtonPointer.rootY);
- !
- ! (* pMouse->processInputProc) (&xE, pMouse, 1);
- ! }
- }
- + pSunPriv->bmask = ev->key;
- + lastEventTime = ev->time;
- }
-
- /*ARGSUSED*/
- ***************
- *** 483,489 ****
- ScreenPtr pScreen;
- Bool entering;
- {
- ! u_char select;
-
- select = 1;
- if (entering)
- --- 384,390 ----
- ScreenPtr pScreen;
- Bool entering;
- {
- ! unsigned char select;
-
- select = 1;
- if (entering)
- ***************
- *** 530,615 ****
- miPointerDeltaCursor (screenInfo.screens[0], dx, dy, TRUE);
- }
- }
- -
- - #ifdef SUN_WINDOWS
- -
- - /*
- - * Process a sunwindows mouse event. The possible events are
- - * LOC_MOVE
- - * MS_LEFT
- - * MS_MIDDLE
- - * MS_RIGHT
- - */
- -
- - void
- - sunMouseProcessEventSunWin(pMouse,se)
- - DeviceRec *pMouse;
- - register struct inputevent *se;
- - {
- - xEvent xE;
- - register int bmask; /* Temporary button mask */
- - register PtrPrivPtr pPriv; /* Private data for pointer */
- - register SunMsPrivPtr pSunPriv; /* Private data for mouse */
- - short x, y;
- -
- - pPriv = (PtrPrivPtr)pMouse->devicePrivate;
- -
- - switch (event_id(se)) {
- - case MS_LEFT:
- - case MS_MIDDLE:
- - case MS_RIGHT:
- - /*
- - * A button changed state. Sometimes we will get two events
- - * for a single state change. Should we get a button event which
- - * reflects the current state of affairs, that event is discarded.
- - *
- - * Mouse buttons start at 1.
- - */
- - pSunPriv = (SunMsPrivPtr) pPriv->devPrivate;
- - xE.u.keyButtonPointer.time = TVTOMILLI(event_time(se));
- - xE.u.u.detail = (event_id(se) - MS_LEFT) + 1;
- - bmask = 1 << xE.u.u.detail;
- - if (win_inputnegevent(se)) {
- - if (pSunPriv->bmask & bmask) {
- - xE.u.u.type = ButtonRelease;
- - pSunPriv->bmask &= ~bmask;
- - } else {
- - return;
- - }
- - } else {
- - if ((pSunPriv->bmask & bmask) == 0) {
- - xE.u.u.type = ButtonPress;
- - pSunPriv->bmask |= bmask;
- - } else {
- - return;
- - }
- - }
- - miPointerPosition (screenInfo.screens[0],
- - &xE.u.keyButtonPointer.rootX, &xE.u.keyButtonPointer.rootY);
- - (* pMouse->processInputProc) (&xE, pMouse, 1);
- - break;
- - case LOC_MOVE:
- - /*
- - * Tell mi to go ahead and generate the event.
- - */
- - miPointerMoveCursor(screenInfo.screens[0], event_x(se),
- - event_y(se), TRUE);
- -
- - /*
- - * Find out if the mouse got constrained. If it did
- - * then we have to tell SunWindows about it.
- - */
- - miPointerPosition (screenInfo.screens[0], &x, &y);
- - if (x != event_x(se) || y != event_y(se))
- - /*
- - * Tell SunWindows that X is constraining the mouse
- - * cursor so that the server and SunWindows stay in sync.
- - */
- - win_setmouseposition(windowFd, x, y);
- - break;
- - default:
- - FatalError ("sunMouseProcessEventSunWin: unrecognized id\n");
- - break;
- - }
- - }
- - #endif SUN_WINDOWS
- --- 431,433 ----
-